<template>
    <div>
        <el-table
            :data="tableData"
            style="width: 100%; margin-bottom: 20px"
            row-key="orderid"
            border
            default-expand-all
            :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
        >
            <el-table-column prop="number" label="订单编号" sortable width="180"> </el-table-column>
            <el-table-column prop="name" label="姓名"> </el-table-column>
            <el-table-column prop="gname" label="商品名"> </el-table-column>
            <el-table-column prop="address" label="地址"> </el-table-column>
            <el-table-column prop="mobile" label="手机号"> </el-table-column>
            <el-table-column prop="price2" label="总价"> </el-table-column>
            <el-table-column prop="gcount" label="商品数量"> </el-table-column>
            <el-table-column prop="opera" label="操作">
                <button>aaa</button>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import url from '../../assets/js/baseurl.js';
export default {
    data() {
        return {
            tableData: []
        };
    },
    methods: {
        send: async function (row) {},
        open: function (msg) {
            this.$message(msg);
        }
    },
    mounted: async function () {
        let res = await this.$http.get(`${url.lxy}/order`);
        for (const i in res.data.data) {
            let j = 1;
            res.data.data[i].gname = '';
            res.data.data[i].gcount = 0;
            res.data.data[i].opera = ''
            for (const xx of res.data.data[i].children) {
                res.data.data[i].gcount += parseInt(xx.gcount);
                xx.orderid = xx.orderid + `'${j}'`;
                xx.price2 = xx.gprice;
                xx.number = '';
                xx.name = '';
                xx.address = '';
                xx.mobile = ''
                j++;
            }
            this.tableData.push(res.data.data[i]);
        }
        console.log(this.tableData);
    }
};
</script>

<style scoped>
</style>